<#import "/common/function.ftl" as fn>
<@fn.header _title="核对业务受理">
	<script language="javascript" type="text/javascript" src="${base}/web/js/jquery.PrintArea.js"></script>
	<script language="javascript" type="text/javascript" src="${base}/web/js/jquery.form.js"></script>
	<script language="javascript" type="text/javascript" src="${base}/web/js/My97DatePicker/WdatePicker.js"></script>
	<script language="javascript" type="text/javascript" src="${base}/web/js/JScript.js"></script>
	<script language="javascript" type="text/javascript" src="${base}/web/js/showDivjs.js"></script>
	<script language="javascript" type="text/javascript">
		var redirectUrl = "${base}/index";
		var totalFiles = 0;
		var fileId = 0;
		
		function	addFile(){
			totalFiles += 1;
			
			var tr = "";
            tr += '<tr id="fileTr'+fileId+'">';
            tr += '<td name="tdFileNum" style="width:50px"></td>';
            tr += '<td><input name="enclosureList['+fileId+'].fileName" type="text" class="input4" require="true" dataType="Limit" min="1" max="50" msg="长度为1~50" /></td>';
            tr += '<td><select name="enclosureList['+fileId+'].category" require="true" dataType="Require" msg="填写不正确"><option value="">请选择</option><#list enclosures as opt><option value="${opt.code}">${opt.name}</option></#list></select></td>';
            tr += '<td><select name="enclosureList['+fileId+'].fileAttr"><option value="原件">原件</option><option value="复印件">复印件</option></select></td>';
            tr += '<td><input name="enclosureList['+fileId+'].fileNum" type="text" style="width:50px" require="true" dataType="Number" msg="填写不正确" /></td>';
            tr += '<td><input name="enclosureList['+fileId+'].filePage" type="text" style="width:50px" require="true" dataType="Number" msg="填写不正确" /></td>';
            tr += '<td><a href="javascript:void(0);" onclick="delFile(\'fileTr'+fileId+'\')">删除</a></td>';
            tr += '</tr>';
			$("#fileTable").append(tr);
			fileId +=1;
			refreshTdNum();
			autoHeight();
		}
		
		function	delFile(id){
			$("tr").remove("#"+id);
			totalFiles -= 1;
			refreshTdNum();
			autoHeight();
		}
		
		function refreshTdNum(){
			$("td[name='tdFileNum']").each(function(i){
				$(this).text(i+1);
			});
		}
		
		$(document).ready(function() { 
		    var options = {
		        beforeSubmit:validate,
		        success:showResponse,
		        dataType:'json'
		    }; 
		    
		    $('#mainForm').submit(function() {
		        $(this).ajaxSubmit(options);
		        return false;
		    });
		}); 
		
		function validate(formData, jqForm, options) {
		    if(!Validator.Validate(jqForm.get(0))){
		    	return false;
		    }
		    for (var i=0; i < formData.length; i++) { 
		        if ((!formData[i].value && formData[i].name != "marriedDate" && formData[i].name != "handleMemo") || 
		        (!formData[i].value && formData[i].name == "marriedDate" && $("select[name='familyMember.maritalStatus']").val()=="01")) { 
		            alert('请将表单信息填写完整！'); 
		            return false; 
		        }
		    }
		    return true; 
		}

		function showResponse(responseText, statusText, xhr, $form)  {
//			alert("showResponse");
		    if(responseText['status'] == "1"){
		    	redirectUrl = responseText['tab'];
		    	
		    	$("#barcode1").attr("src","${base}/barcode/"+responseText['id']);
		    	$("#receipt1_Name").text($("input[name='familyMember.name']").val());
		    	$("#receipt1_No").text(responseText['id']);
		    	$("#receipt1_IdType").text($("#ddlCertType0").find("option:selected").text());
		    	$("#receipt1_IdNumber").text($("input[name='familyMember.idNumber']").val());
		    	$("#receipt1_Tel").text($("input[name='familyMember.phone']").val());
		    	$("#receipt1_Mobile").text($("input[name='familyMember.mobile']").val());
		    	$("#receipt1_Addr").text($("#addrCity").find("option:selected").text()+$("#addrArea").find("option:selected").text()+$("#addrStreet").find("option:selected").text()+$("input[name='familyMember.livingAddress']").val());
		    	$("#receipt1_PoliticalStatus").text($("#politicalStatus").find("option:selected").text());
		    	
		    	$("#barcode2").attr("src","${base}/barcode/"+responseText['id']);
		    	$("#receipt2_Name").text($("input[name='familyMember.name']").val());
		    	$("#receipt2_No").text(responseText['id']);
		    	$("#receipt2_IdType").text($("#ddlCertType0").find("option:selected").text());
		    	$("#receipt2_IdNumber").text($("input[name='familyMember.idNumber']").val());
		    	$("#receipt2_Tel").text($("input[name='familyMember.phone']").val());
		    	$("#receipt2_Mobile").text($("input[name='familyMember.mobile']").val());
		    	$("#receipt2_Addr").text($("#addrCity").find("option:selected").text()+$("#addrArea").find("option:selected").text()+$("#addrStreet").find("option:selected").text()+$("input[name='familyMember.livingAddress']").val());
		    	$("#receipt2_PoliticalStatus").text($("#politicalStatus").find("option:selected").text());

				if(totalFiles > 0){
					var fileName = new Array();
					$("input[name*='].fileName']").each(function(i){
						fileName[i] = $(this).val();
					});
					var fileNum = new Array();
					$("input[name*='].fileNum']").each(function(i){
						fileNum[i] = $(this).val();
					});
					var fileAttr = new Array();
					$("select[name*='].fileAttr']").each(function(i){
						fileAttr[i] = $(this).find("option:selected").text();
					});
/*					var category = new Array();
					$("select[name*='].category']").each(function(i){
						category[i] = $(this).find("option:selected").text();
					});
					*/
					for(var i=0; i<totalFiles; i++){
						var tr="";
			            tr += '<tr>';
			            tr += '<td>'+(i+1)+'</td>';
			            tr += '<td>'+fileName[i]+'</td>';
			            tr += '<td>'+fileNum[i]+'</td>';
			            tr += '<td>'+fileAttr[i]+'</td>';
//			            tr += '<td>'+category[i]+'</td>';
			            tr += '</tr>';
						$("#receipt1_FileTB").append(tr);
						$("#receipt2_FileTB").append(tr);
					}
				}

				var d = new Date();
				var vYear = d.getFullYear();
				var vMon = d.getMonth() + 1;
				var vDay = d.getDate();
				
				var dateStr = vYear + "年" + vMon + "月" + vDay + "日";

				$("#receipt1_Data").text(dateStr);
				$("#receipt2_Data").text(dateStr);
		    	
		    	openNewDiv("divDetail");
		    	$("select").hide();
		    }else if(responseText['status'] == "3"){
		    	alert("申请人身份证号重复！请重新填写！");
		    }else{
		    	alert("数据保存失败！");
		    }
		}
		
		function redirect(){
			parent.selectTab(1);
			window.location.href=redirectUrl;
		}
		
		function setMarryDate(val){
			if(val == "01"){
				$(".married").show();
			}else{
				$(".married").hide();
			}
		}
	</script>
	<style type="text/css">
		.input4 { width:200px; border:1px solid #B6D2E9; padding:2px; }
		.married { display:none; }
	</style>
</@fn.header>
<body>
<form id="mainForm" action="${base}/affairacceptance/save" method="post">

    <div class="rightBk">
    	<@fn.position _value="委托核对 &gt;&gt; 核对业务受理" />

        <!-- 选项卡 -->
        <!-- title -->
       <div class="title marginTop15">
            <div class="title-middle">
                <div class="title-left">
                </div>
                <div class="title-caption">申请人代表基本信息</div>
                <div class="title-right">
                </div>
            </div>
        </div>
              <!-- table -->
        <table class="table1">
            <colgroup class="GridCaption" style="width:12%; background-color: #eef3f7;" ></colgroup>
            <colgroup style="width: 20%;" ></colgroup>
            <colgroup class="GridCaption" style="width:12%; background-color: #eef3f7;" ></colgroup>
            <colgroup style="width: 20%;" ></colgroup>
            <colgroup class="GridCaption" style="width:12%; background-color: #eef3f7;" ></colgroup>
            <colgroup style="width: 20%;" ></colgroup>
            <tr>
                <td>申请人姓名</td>
                <td><input name="familyMember.name" type="text" id="Text6" class="input4" require="true" dataType="Limit" min="1" max="50" msg="长度为1~50"  /></td>
            
            	<td>证件类型</td>
           		<td>
		            <select name="familyMember.idType" id="ddlCertType0" class="select1">
		                <option value="01" selected="selected">身份证</option>
		                <option value="02">护照</option>
		                <option value="03">居住证</option>
		                <option value="04">军官证</option>
		                <option value="05">出生证</option>
		                <option value="06">绿卡</option>
		                <option value="07">港澳通行证</option>
		                <option value="08">其他证件</option>
	            	</select>
            	</td>
            	
            	<td>证件号</td>
            	<td><input name="familyMember.idNumber" type="text" id="txtCertCodeJSF0" class="input4" require="true" dataType="Limit" min="1" max="50" msg="长度为1~50" /></td>
            	
            </tr>
            <tr>
            	<td>性别</td>
           		<td>
		            <select name="gender" class="select1">
		                <option value="01" selected="selected">男</option>
		                <option value="02">女</option>
	            	</select>
            	</td>
                <td>民族</td>
                <td>
                    <select name="familyMember.nation" id="Select8" class="select1">
                        <#list nations as _nation>
                        	<option value="${_nation.code}"<#if _nation.code == "01"> selected</#if>>${_nation.name}</option>
                        </#list>
                    </select>
                </td>
                <td>出生日期</td>
                <td><input name="familyMember.birthday" type="text" class="input4" require="true" dataType="Require" msg="填写不正确" onClick="WdatePicker()" readonly="readonly" /></td>
            </tr>
            <tr>
                <td>政治面貌</td>
                <td>
                    <select name="familyMember.politicalStatus" id="politicalStatus" class="select1">
                      <#list politicalStatus as _politicalStatus>
                        	<option value="${_politicalStatus.code}">${_politicalStatus.name}</option>
                      </#list>
                    </select>
                <td>婚姻状况 </td>
                <td>
                    <select name="familyMember.maritalStatus" class="select1" onclick="setMarryDate(this.value)">
                        <option value="02" selected="selected">未婚</option>
                        <option value="01">已婚</option>
                        <option value="03">离婚</option>
                        <option value="04">丧偶</option>    
                    </select>
                </td>
                <td class="married" style="display:none;">结婚登记日期</td>
                <td class="married" style="display:none;"><input name="marriedDate" type="text" class="input4" onClick="WdatePicker()" readonly="readonly" /></td>
            </tr>
            
            <tr>
			    <td>固定电话</td>
                <td><input name="familyMember.phone" type="text" id="Text6" class="input4" require="true" dataType="Phone" msg="填写不正确" /></td>
                <td>移动电话 </td>
                <td><input name="familyMember.mobile" type="text" id="txtMobileJSF0" class="input4" require="true" dataType="Mobile" msg="填写不正确" /></td>
                <td>邮政编码</td>
                <td><input name="familyMember.zipCode" type="text" class="input4" require="true" dataType="Zip" msg="填写不正确" /></td>
            </tr>            
            <tr>
                <td>户籍所在地</td>
                <td colspan="3">
                    <select id="Select6" class="select1">
                        <option selected="selected" value="01">沈阳市</option>
                    </select>
                    <select name="familyMember.householdDistrictCode" id="Select7" class="select1">
                      <#list citys as city>
                        	<option value="${city.code}">${city.name}</option>
                      </#list>
                    </select>
 	                       派出所
                </td>
                <td>户籍类型</td>
           		<td>
	            <select name="householdType" class="select1">
	                <option value="" selected="selected">请选择</option>
	                <option value="01">农业户口</option>
	                <option value="02">非农业户口</option>
            	</select>
            	</td>
            </tr>       
            <tr>
                <td>现居住地址 </td>
                <td colspan="5">
                    <select id="addrCity" class="select1">
                        <option selected="selected" value="01">沈阳市</option>
                    </select>
                    <select id="addrArea" class="select1">
                      <#list citys as city>
                        	<option value="${city.code}">${city.name}</option>
                      </#list>
                    </select>
                    <select name="familyMember.livingDistrictCode" id="addrStreet" class="select1">
                      <#list streets as street>
                        	<option value="${street.code}">${street.name}</option>
                      </#list>
                    </select>
                    <input name="familyMember.livingAddress" type="text" id="txtMobileJSF0" class="input4" onclick="this.select()" value="请输入街道" require="true" dataType="Limit" min="1" max="50" msg="长度为1~50" />
                </td>
            </tr>

            <tr>
                <td>现居住地开始居住时间</td>
                <td><input name="familyMember.startDateLiving" type="text" class="input4" require="true" dataType="Require" msg="填写不正确" onClick="WdatePicker()" readonly="readonly" /></td>
                <td>文化程度 </td>
                <td>
                	<select name="familyMember.education" id="txtMobileJSF0" class="select1" require="true" dataType="Require" msg="填写不正确">
                	  <option value="">请选择</option>
                      <#list educations as education>
                        	<option value="${education.code}">${education.name}</option>
                      </#list>
                    </select>
               </td>
                <td>健康状况</td>
                <td><input name="familyMember.healthStatus" type="text" id="txtCertCodeJSF1" class="input4" require="true" dataType="Limit" min="1" max="50" msg="长度为1~50" /> （良好 或 差）</td>
            </tr>

            <tr>
                <td>劳动能力丧失状况</td>
                <td>
					<select name="familyMember.laborLossStatus" id="txtMobileJSF0" class="select1" require="true" dataType="Require" msg="填写不正确">
					  <option value="">请选择</option>
	                  <#list laborlost as ll>
	                    	<option value="${ll.code}">${ll.name}</option>
	                  </#list>
	                </select>
                </td>
                <td>残疾等级</td>
           		<td>
	            <select name="familyMember.disabilityDegree" class="select1" require="true" dataType="Require" msg="填写不正确">
	                  <option value="">请选择</option>
	                  <#list disabilityDegree as ll>
	                    	<option value="${ll.code}">${ll.name}</option>
	                  </#list>
            	</select>
            	</td>
                <td>所患主要疾病名称</td>
                <td><input name="familyMember.diseaseName" type="text" class="input4" require="true" dataType="Limit" min="1" max="50" msg="长度为1~50" /> （没有可以填无）</td>
            </tr>
        </table>
        
        <div class="title marginTop15">
            <div class="title-middle">
                <div class="title-left"></div>
                <div class="title-caption">受理信息</div>
                <div class="title-right">
            </div>
            </div>
        </div>
        <!-- table -->
        <table class="table1">
            <colgroup>
                <col class="GridCaption" style="width:12%; background-color: #eef3f7;" />
                <col style="width: 250px;" />
                <col class="GridCaption" style="width:12%; background-color: #eef3f7;" />
                <col />
            </colgroup>
            <tr>
                <td>受理机构</td>
                <td>
                    <select name="handleOrg" id="Select5" class="select1">
	                      <#list streets as street>
	                        	<option value="${street.code}">${street.name}</option>
	                      </#list>
                    </select>
                </td>
                <td>受理意见</td>
                <td>
                    <input checked="checked" id="handleStatus1" name="handleStatus" type="radio" value="HANDLE" /><label for="handleStatus1">申请材料完整有效，予以受理</label> 
                    <input id="handleStatus2" name="handleStatus" type="radio" value="NOT_HANDLE" /><label for="handleStatus2">申请材料不完整，不予受理</label>
                </td>
            </tr>
            <tr>
                <td>备注</td>
                <td>
                    <input name="handleMemo" type="text" id="Text9" class="input4" maxlength="250"/></td>
                <td></td>
                <td>
                </td>
            </tr>
            </table>
        <div class="title marginTop15">
            <div class="title-middle">
                <div class="title-left"></div>
                <div class="title-caption">申请材料</div>
                <div class="title-right"></div>
            </div>
        </div>
        <!-- table -->
        <table class="table1" id="fileTable">
            <colgroup>
                <col class="GridCaption" style="width:30px;"/>
                <col />
                <col class="GridCaption" style="width:50px;" />
                <col style="width:50px;"/>
                <col style="width:50px;"/>
            </colgroup>
            <tr>
                <td style="width:50px">序号</td>
                <td>材料名称</td>
                <td style="width:200px">文件类型</td>
                <td style="width:100px">文件属性</td>
                <td style="width:130px">份数</td>
                <td style="width:50px">页数</td>
                <td style="width:30px"><a href="javascript:void(0);" onclick="addFile();">增加</a></td>
            </tr>
            <!--
            <tr>
                <td>1</td>
                <td><input name="" type="text" class="input4" /></td>
                <td><input name="" type="text" style="width:50px" /></td>
                <td><input name="" type="text" style="width:50px" /></td>
                <td></td>
            </tr>
            -->
            </table>
        <div class="marginTop15 alignCenter">
        	<input type="image" src="${base}/web/img/btnSubmit.gif" border="0" />
        	<!--
            <a href="javascript:void(0);" onclick="openNewDiv('divDetail');$('select').hide();"><img src="${base}/web/img/btnAccept.gif" border="0" alt="" /></a>
			-->
        </div>
    </div>
    
</form>  

  <div id="tools">
  <div class="materialsDiv" id="divDetail" style="display:none; width: 900px; height:550px;">
    <div class="materialsTitle">
      <div class="materialsTitleL"><a href="javascript:void(0);" onclick="$('#myPrintArea').printArea();redirect();return false;"><img src="${base}/web/img/btnPrint.gif" style="margin-top:3px;" border="0" /></a></div>
      <div class="materialsTitleR"><a href="javascript:void(0);" onclick="redirect();return false;"><img src="${base}/web/img/close.gif"  border="0" /></a></div>
    </div>
    <div style="height:500px;overflow:auto;clear:both;" id="myPrintArea">
	     <div class="receipt">
		  <h1>受理回执单</h1>
		  <h2>第一联申请人留存</h2>
		  <div class="barcode"><img id="barcode1" src="" width="443" height="45" /></div>
		  <table class="receiptTb">
		    <tr>
		      <td>申请人姓名：</td>
		      <td><label id="receipt1_Name"></label></td>
		      <td>事务受理号：</td>
		      <td><label id="receipt1_No"></label></td>
		    </tr>
		    <tr>
		      <td>证件类型：</td>
		      <td><label id="receipt1_IdType"></label></td>
		      <td>证件号码：</td>
		      <td><label id="receipt1_IdNumber"></label></td>
		    </tr>
		    <tr>
		      <td>固定电话：</td>
		      <td><label id="receipt1_Tel"></label></td>
		      <td>移动电话：</td>
		      <td><label id="receipt1_Mobile"></label></td>
		    </tr>
		    <tr>
		      <td>地址：</td>
		      <td><label id="receipt1_Addr"></label></td>
		      <td>政治面貌：</td>
		      <td><label id="receipt1_PoliticalStatus"></label></td>
		    </tr>
		  </table>
		  <h3>申请材料</h3>
		  <table class="receiptGd" id="receipt1_FileTB">
		    <tr>
		      <th>序号</th>
		      <th>材料名称</th>
		      <th>份数</th>
		      <th>文件属性</th>
		    </tr>
		  </table>
		  <table class="receiptGd">
		    <tr>
		      <td colspan="4">备注：</td>
		    </tr>
		    <tr>
		      <td colspan="4"><textarea cols="45" rows="5" class="textArea" id="receipt1_TextArea" onkeyup="$('#receipt2_TextArea').text(this.text())"></textarea></td>
		    </tr>
		  </table>
		  <div class="date" id="receipt1_Data"></div>
		</div>
	     <div class="receipt">
		  <h1>受理回执单</h1>
		  <h2>第二联中心留存</h2>
		  <div class="barcode"><img id="barcode2" src="" width="443" height="45" /></div>
		  <table class="receiptTb">
		    <tr>
		      <td>申请人姓名：</td>
		      <td><label id="receipt2_Name"></label></td>
		      <td>事务受理号：</td>
		      <td><label id="receipt2_No"></label></td>
		    </tr>
		    <tr>
		      <td>证件类型：</td>
		      <td><label id="receipt2_IdType"></label></td>
		      <td>证件号码：</td>
		      <td><label id="receipt2_IdNumber"></label></td>
		    </tr>
		    <tr>
		      <td>固定电话：</td>
		      <td><label id="receipt2_Tel"></label></td>
		      <td>移动电话：</td>
		      <td><label id="receipt2_Mobile"></label></td>
		    </tr>
		    <tr>
		      <td>地址：</td>
		      <td><label id="receipt2_Addr"></label></td>
		      <td>政治面貌：</td>
		      <td><label id="receipt2_PoliticalStatus"></label></td>
		    </tr>
		  </table>
		  <h3>申请材料</h3>
		  <table class="receiptGd" id="receipt2_FileTB">
		    <tr>
		      <th>序号</th>
		      <th>材料名称</th>
		      <th>份数</th>
		      <th>文件属性</th>
		    </tr>
		  </table>
		  <table class="receiptGd">
		    <tr>
		      <td colspan="4">备注：</td>
		    </tr>
		    <tr>
		      <td colspan="4"><textarea cols="45" rows="5" class="textArea" id="receipt2_TextArea" onkeyup="$('#receipt1_TextArea').text(this.text())"></textarea></td>
		    </tr>
		  </table>
		  <div class="date" id="receipt2_Data"></div>
		</div>
    </div>
  </div>
  </div>
  
</body>
</html>